
#ifndef LIB_INT_H_
#define LIB_INT_H_

#include "global.h"

/*
#define MB_TIMER_PRESCALER		( 1024UL )
#define MB_TIMER_TICKS			( F_CPU / MB_TIMER_PRESCALER )
#define MB_50US_TICKS			( 20000UL )

static USHORT   usTimerOCRADelta=0;
//static USHORT   usTimerOCRBDelta;

BOOL xMBPortTimersInit  (USHORT usTim1Timerout50us)
{
    // Calculate overflow counter an OCR values for Timer1.
    usTimerOCRADelta = ( MB_TIMER_TICKS * usTim1Timerout50us ) / ( MB_50US_TICKS );
    TCCR1A = 0x00;
    TCCR1B = 0x00;
    TCCR1C = 0x00;
    vMBPortTimersDisable();
    return TRUE;
}

void vMBPortTimersEnable()
{
    TCNT1 = 0x0000;
    if( usTimerOCRADelta > 0 )
    {
        TIMSK1 |= _BV( OCIE1A );
        OCR1A = usTimerOCRADelta;
    }
    TCCR1B |= _BV( CS12 ) | _BV( CS10 );
}

void vMBPortTimersDisable()
{
    // Disable the timer.
    TCCR1B &= ~( _BV( CS12 ) | _BV( CS10 ) );
    // Disable the output compare interrupts for channel A/B.
    TIMSK1 &= ~( _BV( OCIE1A ) );
    // Clear output compare flags for channel A/B.
    TIFR1 |= _BV( OCF1A ) ;
}

//SIGNAL( SIG_OUTPUT_COMPARE1A )
//{
//    ( void )pxMBPortCBTimerExpired(  );
//}



//void	MYLIBSECTION	InitWD();
//BOOL  xMBPortTimersInit( USHORT usTim1Timerout50us );
//void MYLIBSECTION vMBPortTimersEnable();
//void MYLIBSECTION vMBPortTimersDisable();
*/


#endif /* LIB_INT_H_ */
